package com.bona.dao.system;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.bona.dao.common.BaseDao;

/**
 * 用户基础信息类
 * @author tbzeng
 *
 */
public interface SysUserDao extends BaseDao {
	
	/**
	 * 获取部门下的用户id
	 * @param orgId
	 * @return
	 */
	@Select("SELECT user_id FROM sys_user_org WHERE org_id=#{orgId}")
	public List<String> queryUserIdsByOrgId(@Param("orgId")String orgId);
	
	/**
	 * 查询用户所关联的角色编号
	 * @param userId
	 * @return
	 */
	@Select("SELECT roleid FROM sys_role_user WHERE userid=#{userId}" +
	" UNION	" +
	" SELECT t1.role_id FROM sys_role_org t1 JOIN sys_user_org t2 ON t1.org_id=t2.org_id " +
	" WHERE t2.user_id=#{userId}")
	public List<String> queryRoleIdsByUserId(@Param("userId")String userId);
	
}
